package com.hanter.downloader.service;

import androidx.annotation.Nullable;

/**
 * 文件名：HttpMethod <br/>
 * 描述：Http请求方法
 * 创建时间：2022/02/08 09:13
 *
 * @author wangmingshuo
 * @version 1.0
 */
class HttpUtils {

    public static final String HEAD = "HEAD";
    public static final String GET = "GET";
    public static final String POST = "POST";
    public static final String PUT = "PUT";


    @Nullable
    public static String getRangeHeader(long start, long end) {
        // -1 表示不用断点续传
        // 当前分块单位仅支持 bytes
        // https://www.iana.org/assignments/http-parameters/http-parameters.xhtml#range-units
        if (start == -1L) return null;

        if (end == -1) {
            return "bytes=" + start + "-";
        } else {
            return "bytes=" + start + "-" + end;
        }
    }

}
